package com.design.boot.task;

/**
 * @author kakayubei
 * @description
 * @date 2021/7/31 12:28
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 任务类
 */
@Component
public class MySpringTask {
    protected Logger log = LoggerFactory.getLogger(getClass());
    /**
     * 每2秒执行1次
     */
    @Scheduled(fixedRate = 2000)
    public void fixedRateMethod() throws InterruptedException {
        log.info("fixedRateMethod:{}", new Date());
        Thread.sleep(1000000);
    }

    @Scheduled(cron = "0 0 * * * ?")
    public void jump() {
        log.info("心跳检测:{}", new Date());
    }
}

